// 268. 丢失的数字
class Solution {
public:
    int map[10005] = {0};
    int missingNumber(vector<int>& nums) {
        for(auto e : nums)
        {
            map[e]++;
        }
        for(int i = 0; i <= nums.size(); i++)
        {
            if(map[i] == 0) return i;
        }
        return 0;

    }
};

// 932. 漂亮数组
class Solution {
public:
    unordered_map<int, vector<int>> map;
    vector<int> beautifulArray(int n) {
        vector<int> ret;
        if(1 == n)
        {
            ret.push_back(1);
            return ret;
        }
        if(map.count(n)) return map[n];
        int odd = n - n/2;
        int even = n/2;

        vector<int> left = beautifulArray(odd);
        vector<int> right = beautifulArray(even);
        for(auto e : left) ret.push_back(2*e-1);
        for(auto e : right) ret.push_back(2*e);

        map[n] = ret;
        return ret;
    }
};